package com.kitchen.ui.com
{
	import com.kitchen.AbstractIcon;
	import com.kitchen.ui.com.icon.PiercedNumberIcon;
	
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
	
	public class PiercedNumber extends Sprite
	{
		private var numIcon:AbstractIcon;
		private var checkLayer:Shape = null;
		private var checked:Boolean = false;
		public var h:Number;
		public var w:Number;
		public var num:int;
		
		public function PiercedNumber(mbitmapData:BitmapData)
		{
			super();
			this.h = 18;
			this.w = 18;
			this.num = 0;
			this.layout(mbitmapData);
			var lmask:Shape = new Shape();
			lmask.graphics.beginFill(0xffffff, 1);
			lmask.graphics.drawRect(0, 0, this.w, this.h);
			lmask.graphics.endFill();
			this.mask = lmask;
			this.addChild(lmask);
			this.useHandCursor = true;
			this.buttonMode = true;
		}
		
		private function layout(main:BitmapData):void{
			this.numIcon = new PiercedNumberIcon(main);
			this.numIcon.x = -(this.num*18);
			this.addChild(this.numIcon);
		}
		
		public function setChecked(check:Boolean):void{
			this.checked = check;
			if(this.checkLayer == null){
				this.checkLayer = new Shape();
				this.checkLayer.graphics.lineStyle(2, 0xa96b42);
				this.checkLayer.graphics.beginFill(0xff0000, 0.2);
				this.checkLayer.graphics.drawRect(0, 0, this.w,this.h);
				this.addChild(this.checkLayer);
			}
			this.checkLayer.visible = this.checked;
		}
		
		public function show(num:int):void{
			this.num = num;
			this.numIcon.x = -(num*18);
		}
	}
}